home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / winsrc.arc / PROFILE.C < prev    next >
C/C++ Source or Header  |  1991-06-16  |  3KB  |  140 lines

  1. #include <windows.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "winfract.h"
  5. #include "profile.h"
  6.  
  7. extern int xdots, ydots, Sizing;
  8. extern int ZoomBarOpen, CoordBoxOpen;
  9.  
  10. static char None[]      = "None";
  11. static char SSTools[80];
  12. static char True[]      = "True";
  13. static char False[]     = "False";
  14. static char Yes[]       = "Yes";
  15. static char One[]       = "1";
  16. static char Zero[]      = "0.0";
  17.  
  18. static BOOL NoSave = FALSE;
  19.  
  20. char Winfract[]  = "Winfract";
  21. char Fractint[]  = "Fractint";
  22. char *ProgStr = Winfract;
  23.  
  24. void SetToolsPath(void) {
  25.    static char FileName[] = "sstools.ini";
  26.  
  27.    findpath(FileName, SSTools);
  28.    if(!*SSTools)
  29.       strcpy(SSTools, FileName);
  30. }
  31.  
  32. BOOL GetParamSwitch(char *Key) {
  33.    char Text[80];
  34.  
  35.    GetPrivateProfileString(ProgStr, Key, None, Text, sizeof(Text), SSTools);
  36.    if(!stricmp(Text, True) ||
  37.       !stricmp(Text, Yes) ||
  38.       !stricmp(Text, One)
  39.    ) return(TRUE);
  40.    return(FALSE);
  41. }
  42.  
  43. double GetFloatParam(char *Key, double Def) {
  44.    char Text[80];
  45.  
  46.    GetPrivateProfileString(ProgStr, Key, None, Text, sizeof(Text), SSTools);
  47.    if(!stricmp(None, Text))
  48.       return(Def);
  49.    return(atof(Text));
  50. }
  51.  
  52. double GetIntParam(char *Key, int Def) {
  53.    char Text[80];
  54.  
  55.    GetPrivateProfileString(ProgStr, Key, None, Text, sizeof(Text), SSTools);
  56.    if(!stricmp(None, Text))
  57.       return(Def);
  58.    return(atoi(Text));
  59. }
  60.  
  61. void SaveParamStr(char *Key, char *Str) {
  62.    if(!NoSave)
  63.       WritePrivateProfileString(ProgStr, Key, Str, SSTools);
  64. }
  65.  
  66. void SaveFloatParam(char *Key, double Num) {
  67.    char Str[80];
  68.  
  69.    sprintf(Str, "%g", Num);
  70.    SaveParamStr(Key, Str);
  71. }
  72.  
  73. void SaveIntParam(char *Key, int Num) {
  74.    char Str[80];
  75.  
  76.    sprintf(Str, "%d", Num);
  77.    SaveParamStr(Key, Str);
  78. }
  79.  
  80. void SaveParamSwitch(char *Key, BOOL Flag) {
  81.    char *Str;
  82.  
  83.    if(Flag)
  84.       Str = True;
  85.    else
  86.       Str = False;
  87.    SaveParamStr(Key, Str);
  88. }
  89.  
  90. void PositionWindow(HWND hWnd, char *Key) {
  91.    char Text[80];
  92.    POINT Pos;
  93.  
  94.    GetPrivateProfileString(Winfract, Key, None, Text, sizeof(Text), SSTools);
  95.    if(stricmp(Text, None)) {
  96.       sscanf(Text, "%d, %d", &Pos.x, &Pos.y);
  97.       NoSave = TRUE;
  98.       SetWindowPos(hWnd, GetNextWindow(hWnd, GW_HWNDPREV), Pos.x, Pos.y,
  99.                    0, 0, SWP_NOSIZE);
  100.       NoSave = FALSE;
  101.    }
  102. }
  103.  
  104. void SaveWindowPosition(HWND hWnd, char *Key) {
  105.    char Text[80];
  106.    RECT Rect;
  107.  
  108.    GetWindowRect(hWnd, &Rect);
  109.    sprintf(Text, "%d, %d", Rect.left, Rect.top);
  110.    SaveParamStr(Key, Text);
  111. }
  112.  
  113. char WindowSizingStr[]     = "WindowSizing";
  114. char ImageWidthStr[]       = "ImageWidth";
  115. char ImageHeightStr[]      = "ImageHeight";
  116. char ZoomBoxStr[]          = "ZoomBoxOpen";
  117. char CoordBoxStr[]         = "CoordinateBoxOpen";
  118. char WinfractPosStr[]      = "WinfractPosition";
  119. char ZoomBoxPosStr[]       = "ZoomBoxPosition";
  120. char CoordBoxPosStr[]      = "CoordBoxPosition";
  121.  
  122. void InitializeParameters(HWND hWnd) {
  123.    NoSave = TRUE;
  124.  
  125.    xdots = GetIntParam(ImageWidthStr, 200);
  126.    ydots = GetIntParam(ImageHeightStr, 150);
  127.  
  128.    PositionWindow(hWnd, WinfractPosStr);
  129.    if(GetParamSwitch(WindowSizingStr) != Sizing)
  130.       WindowSizing(hWnd);
  131.    if(GetParamSwitch(ZoomBoxStr) != ZoomBarOpen)
  132.       ZoomBar(hWnd);
  133.    if(GetParamSwitch(CoordBoxStr) != CoordBoxOpen)
  134.       CoordinateBox(hWnd);
  135.    NoSave = FALSE;
  136. }
  137.  
  138. void SaveParameters(HWND hWnd) {
  139. }
  140.